package com.vteApp.dal;

import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;

public class RiskDB {
	final static String TABLE_NAME = "risk";
	final static String KEY_ID = "_id";
	final static String KEY_FACTOR = "factor";
	final static String KEY_TITLE = "title";
	final static String KEY_REQUIRED = "required";
	final static String KEY_VALUE = "value";

	private static final String DATABASE_CREATE = "create table risk "
			+ "(_id integer primary key autoincrement, "
			+ "factor integer not null, " + "title text not null,"
			+ " required integer not null," + "value integer not null);";

	public static void onCreate(SQLiteDatabase database) {
		database.execSQL(DATABASE_CREATE);
		insertRisks(database);
	}

	public static void insertRisks(SQLiteDatabase database) {
		createRisk(database, 1, "Age 41/60 Years", true);
		createRisk(database, 1, "Minor Surgery Planned", false);
		createRisk(database, 1, "History of prior major surgery", false);
		createRisk(database, 1, "Valcose Viens", false);
		createRisk(database, 1, "History of inflammatory bowel", false);
		createRisk(database, 1, "Swollen legs(Current)", false);
		createRisk(database, 1, "Obesity (BMI>30)", false);
		createRisk(database, 1, "Acute myocardial infraction (< 1 month)",
				false);
		createRisk(database, 1, "Congestive health failure (< 1 month)", false);
		createRisk(database, 1, "Sepsis (< 1 month)", false);
		createRisk(database, 1,
				"serous lung disease including pnumonia (< 1 month)", false);
		createRisk(database, 1, "Abnormal Pulmonary Function (COPD)", false);
		createRisk(database, 1, "Medical Patient current at bed rest", false);
		createRisk(database, 1, "Leg plastercast Orbace", false);
		createRisk(database, 2, "Age 60-74 yrs", false);
		createRisk(database, 2, "Major Surgery (>60 minutes)", false);
		createRisk(database, 2, "Arthroscopic surgery (>60 minutes)", false);
		createRisk(database, 2, "Laparoscopic Surgery (>60 minutes)", false);
		createRisk(database, 2, "Previous malignancy", false);
		createRisk(database, 2, "Central cenous access", false);
		createRisk(database, 2, "Morobid obesity (BMI>40)", false);
		createRisk(database, 3, "Age over 75", false);
		createRisk(database, 3, "Major Surgery lasting 2-3 hours", false);
		createRisk(database, 3, "BMI > 50 (venous stasis syndrome)", false);
		createRisk(database, 3, "History of SVT, DVT/PE", false);
		createRisk(database, 3, "Family history of DVT/PE", false);
		createRisk(database, 3, "Present cancer or chemotherapy", false);
		createRisk(database, 3, "Positive factor V leiden", false);
		createRisk(database, 3, "Positive Prothromnin 20210A", false);
		createRisk(database, 3, "Elevated serum homocysteine", false);
		createRisk(database, 3, "Positive Lupus anticagulant", false);
		createRisk(database, 3, "Elevated anticario antibodies", false);
		createRisk(database, 3, "Heparin- induced thrombocytopenuia(HIT)",
				false);
		createRisk(database, 5, "Elective major lower extrimity arthroplasty",
				false);
		createRisk(database, 5, "Hip, pelvis or leg fracture (<1 month)", false);
		createRisk(database, 5, "Stroke <1 month", false);
		createRisk(database, 5, "Multiple trauma(<1 month)", false);
		createRisk(database, 5,
				"Actual Spinal Cord injury(paralysis) <1 month", false);
		createRisk(database, 5, "Major surgery lasting over 3 hours", false);
		createRisk(database, 5, "Elevated anticario antibodies", false);
		createRisk(database, 5, "Elevated anticario antibodies", false);
		createRisk(database, 6,
				"Oral Contraceptive or hormone replacement therapy", false);
		createRisk(database, 6, "Pregnancy or post partum(<1 month)", false);
		createRisk(
				database,
				6,
				"History of unexplained stillborn infant, \nrecurrent spontaneous abortion (>2), \npremature birth with toxemia \nor growth restricted infant",
				false);
	}

	public static long createRisk(SQLiteDatabase database, int factor,
			String title, Boolean required) {
		ContentValues values = new ContentValues();
		values.put(KEY_FACTOR, factor);
		values.put(KEY_TITLE, title);
		values.put(KEY_REQUIRED, required);
		values.put(KEY_VALUE, 1);
		return database.insert(TABLE_NAME, null, values);
	}

}
